<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<%@ include file="/static/admin/jsp/include.jsp"%>
<script type="text/javascript">
	//vip退款
	var grid;
	var logs = function(id) {
		var url = sy.contextPath + '/go?path=order/goodsOrderDetails&id=' + id;
		var dialog = parent.sy.modalDialog({
			title : '订单详情',
			width : 1000,
			height : 600,
			url : url
		});
	};
    var send = function(id) {
        var url = sy.contextPath + '/go?path=/order/expressEdit&id=' + id;
        var dialog = parent.sy.modalDialog({
            title : '物流信息',
            width : 500,
            height : 300,
            url : url,
            buttons : [ {
                text : '保存',
                handler : function() {
                    dialog.find('iframe').get(0).contentWindow.submitForm(dialog, grid, parent.$);
                }
            } ]
        });
    };

    /**
	 * 退款
     */
    function vipRefundUser(id){
        parent.$.messager.confirm("询问","请确保该交易流水在支付宝/微信商家平台已退款成功", function(r) {
            if (r) {
                var url = sy.contextPath + '/pawnBailVip/save';
                $.post(url, {id:id,refundState:2}, function(result) {
                    grid.datagrid('reload');
                }, 'json');
            }
        });
	}

	$(function() {
		
		grid = $('#grid').datagrid({
			url : sy.contextPath + '/pawnBailVip/list',
			singleSelect : true,
			columns : [ [ 
				{
					width : $(this).width() * 0.2,
					title : '用户账号',
					field : 'userAccount',
					align : 'center'
				},{
					width : $(this).width() * 0.2,
					title : '交易流水',
					field : 'tradeNo',
					align : 'center'
				},{
					width : $(this).width() * 0.2,
					title : '交易平台',
					field : 'payPlatform',
					align : 'center',
					formatter : function (v,r,i) {
						if(v == 1){
							return '支付宝'
						}else if(v == 2){
							return '微信';
						}else{
							return '--'
						}
                    }
				},{
					width : $(this).width() * 0.1,
					title : '操作',
					field : 'op',
					align : 'center',
					formatter:function(value, row, index){
                        var html = '';
					    if(row.refundState == 1){
							//申请退款
                            html += '<a href="javascript:void(0);" onclick="vipRefundUser(\''+row.id+'\')" class="button button-info" title="退款">退款</a>';
						}else if(row.refundState == 2){
					        //退款成功
							return '退款成功';
						}
						return html;
					}
				}
			] ]
		});
	});

    /**
     * 导出excel
     */
    function exportExcel(){
        var url = sy.contextPath + 'pawnBailVip/exportExcel';
        location.href=url;
    }
</script>
</head>
<body>
	<div id="toolbar">
		<form id="searchForm">
		<div>
			<span>搜索：</span>
			<input type="text" class="easyui-textbox" name="account" style="width: 150px" prompt="用户账号"/>
			<input type="text" class="easyui-textbox" name="tradeNo" style="width: 150px" prompt="交易流水号"/>
			<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'fa-search'" onclick="grid.datagrid('load',sy.serializeObject($('#searchForm')));">过滤</a> 
			<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'fa-search-minus'" onclick="$('#searchForm input').val('');grid.datagrid('load',{});">重置过滤</a>
			<a href="javascript:void(0);" onclick="exportExcel();" class="button button-red" title="导出excel">导出excel</a>
		</div>
		</form>
		<!-- <div class="tbbutton">
			<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'fa-plus-circle',plain:true" onclick="addFun();">添加</a>
			<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'fa-pencil',plain:true" onclick="editFun();">修改</a>
			<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'fa-trash',plain:true" onclick="delFun();">删除</a>
			<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'fa-key',plain:true" onclick="idFun();">查看ID</a>
		</div> -->
	</div>
	<table id="grid" data-options="fit:true,border:false"></table>
</body>
</html>